#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<windows.h>

int main()
{
	int i,j;
	int x = 10;
	int y = 5;	
	char input;
	int isFired = 0;
	int y2=5;
	int isKilled =0;
	int v = 3;
	int score=0;
	
	while (1)
	{
		system("cls");
		if (1 > y2 || y2 > 20)
			v = -1*v;   //靶子移动
		y2=y2+v;
		for (j=0;j<=y2;j++)//输出靶子
			printf(" ");
		if (isKilled == 0)
			printf ("$\n");
		else
		{
			printf ("\n");
			isKilled = 0;
		}
		
		if (isFired == 0)
		{
			for (i=0;i<x;i++)
				printf (" \n");
		}
		
		else
		{
			for (i=0;i<x;i++)
			{
				for (j=0;j<y;j++)
					printf(" ");
				printf("  |\n");//输出子弹
			}
			isFired = 0;
		}
		if (y + 1 == y2)
		{
			isKilled = 1;
			score++;
		}
		for (j=0;j<y;j++)//输出飞机
			printf(" ");
		printf ("  *\n");
		for (j=0;j<y;j++)
			printf(" ");
		printf ("*****\n");
		for (j=0;j<y;j++)
			printf(" ");
		printf (" * *\n");	
		printf ("\n");
		printf("score:%d",score);
		input = getch();//方向操控
		if (input=='s')
			x++;
		if (input=='w')
			x--;
		if (input=='a')
			y--;
		if (input=='d')
			y++;
		if (input=='j')
			isFired = 1;
	}
	return 0;
}